{extend name="web/public/base" /}
{block name="header"}
{/block}
{block name="main"}
<section class="scrollable padder">
    <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
        <li><a><i class="fa fa-home"></i> 首页</a></li>
        <li class="active">财务中心</li>
        <li class="active">{$title}</li>
    </ul>
    <div class="row">
        <div class="col-sm-12">
            <section class="panel panel-default">
                <header class="panel-heading">
                    {$title}
                    <button onclick="setDay();return false;"
                            style="margin-left: 20px;border: none;background-color: red;color: #ffffff;padding: 5px 10px">
                        生成今日分红
                    </button>
                </header>
                {include file="web/public/search" /}
                {notempty name="_list"}
                <div class="table-responsive">
                    <table class="table table-striped table-hover b-t b-light text-sm">
                        <thead>
                        <tr>
                            <th>时间</th><th>消费商人数</th><th>代理商人数</th><th>经销商人数</th>
                            <th>合伙人人数</th><th>代理商分红总额</th><th>经销商分红总额</th><th>状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name='_list' id='vo'}
                        <tr>
                            <td>{$vo.count_date|date="Y-m-d H:i:s",###}</td>
                            <td>{$vo.level1}</td>
                            <td>{$vo.level2}</td>
                            <td>{$vo.level3}</td>
                            <td>{$vo.level4}</td>
                            <td>{$vo.money1|format_num}</td>
                            <td>{$vo.money2|format_num}</td>
                            <td>
                                {if condition="$vo.status eq 0 "}<span style="color:green">待分红</span>{/if}
                                {if condition="$vo.status eq 1 "}<span style="color:red">已分红</span>{/if}
                            </td>
                            <td>{if condition="$vo.status eq 0 "}
                                <button onclick="fafang({$vo.id});return false;">立即发放</button>
                                <a href="{:url('edit',['id'=>$vo['id']])}">编辑</a>
                                <a href="{:url('dayDetail',['id'=>$vo['id']])}">详情</a>
                                {/if}
                                {if condition="$vo.status eq 1 "}无{/if}
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
                <footer class="panel-footer">
                    <div class="row">
                        <div class="text-right text-center-xs">
                            {$page}
                        </div>
                    </div>
                </footer>
                {else/}
                <div style="text-align: center">
                    <image src="__PUBLIC__/images/empty.jpg"></image>
                </div>

                {/notempty}
            </section>
        </div>
    </div>
</section>
{/block}
{block name="script"}
<script>
    function fafang(id){
        layer.confirm('确定要发放该分红吗？', function () {
            var index = layer.load('正在跳转，请耐心等待');
            $.post("{:url('dayDivid')}", {id: id}, function (data) {
                layer.close(index);
                layer.msg(data.msg);
                location.reload();
            }, "json");
            return false;
        })
    }

    function setDay() {
        $.post("{:url('setDayData')}", function (data) {
            layer.msg(data.msg);
            setTimeout(function () {
                location.reload();
            }, 2000)
        }, "json");
        return false;
    }
</script>
{/block}
{block name="footer"}
{/block}